package cn.wolfcode.luowowo.acticle.domain;

import cn.wolfcode.luowowo.common.domain.BaseDomain;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import static cn.wolfcode.luowowo.common.util.LocalDateTimeUtil.dateToWeekday;

@Getter
@Setter
public class Planeticket extends BaseDomain {
    private String departcity;   //出发地址

    private String destcity;       //到达地址

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date startdate;         //出发日期

    private String weekday;         //周期

    private String flightname;      //航班信息

    private String takeoff_time;        //起飞时间

    private String takeoff_airport;     //起飞机场

    private String arrive_time;         //落地时间

    private String arrive_airport;      //落地机场

    private String flight_time;         //飞行时间

    private String price;           //价格

    private String totalPrice;           //总价格

    private String upkeep;          //保养费用

    public String getJsonString() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("departcity", departcity);

        map.put("destcity", destcity);

        map.put("startdate", startdate);

        map.put("flightname", flightname);

        map.put("takeoff_time", takeoff_time);

        map.put("takeoff_airport", takeoff_airport);

        map.put("arrive_time", arrive_time);

        map.put("arrive_airport", arrive_airport);

        map.put("flight_time", flight_time);

        map.put("price", price);

        map.put("upkeep", upkeep);
        return JSON.toJSONString(map);
    }

    public String getWeekday(){
        return dateToWeekday(startdate);
    }
}